﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <meta name="author" content="leipi.org">

    <link href="~/FlowJs/css/bootstrap/css/bootstrap.css?v7" rel="stylesheet" />
    <link href="~/Content/bootstrap.css?v1" rel="stylesheet" />
    <link href="~/FlowJs/css/site.css" rel="stylesheet" />
    <link href="~/FlowJs/js/flowdesign/flowdesign.css?v1" rel="stylesheet" />
    <link href="~/FlowJs/js/jquery.multiselect2side/css/jquery.multiselect2side.css" rel="stylesheet" />
    <link href="~/FlowJs/BootstrapSelect/css/bootstrap-select.css" rel="stylesheet" />
    @*<link href="~/FlowJs/css/bootstrap.css?v=1.2" rel="stylesheet" />*@
    <title>Index</title>
</head>
<body>

    <div class="navbar navbar-inverse navbar-fixed-top">

        <div class="navbar-inner">
            <div class="container ">
                <div class="row center">
                    <div class="pull-left col-lg-4 center ">
                        <lable class="btn btn-defult" style="width:650px;" id="lblText">【@ViewBag.lblText】审批流程图设计</lable>
                    </div>
                    <div class="pull-right col-lg-4">
                        <button class="btn btn-info" type="button" id="save">保存设计</button>
                        <button class="btn btn-danger" type="button" id="clear">清空连接</button>
                        <button class="btn btn-defult" type="button" data-toggle="modal" id="BtnBack">返回</button>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <!-- Modal -->
    <div class="modal fade" id="alertModal" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3>消息提示</h3>
                </div>
                <div class="modal-body">
                    <p>提示内容</p>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">我知道了</button>
                </div>
            </div>
        </div>
    </div>
    <!-- attributeModal -->
    @*<div id="attributeModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:800px;margin-left:-350px">*@
    <div class="modal fade" id="attributeModal" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header green">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        属性设置
                    </h4>
                </div>
                <div class="modal-body">
                    <div class="box-body">
                        <ul id="myTab" class="nav nav-tabs">
                            <li class="active">
                                <a href="#Set1" data-toggle="tab">
                                    常规
                                </a>
                            </li>
                            <li id="KSLiID">
                                <a href="#Set2" data-toggle="tab">
                                    属性
                                </a>
                            </li>
                        </ul>
                        <div id="myTabContent" class="tab-content" style="    margin-top: 10px;">
                            <div class="tab-pane fade in active" id="Set1">
                                <div class="box-body">
                                    @*<iframe id="iframeID" width="100%" height="600px" style="border:0px" src="/Home/AttributeView">
                                        </iframe>*@
                                    <form class="form-horizontal" id="NormalFormID">
                                        <div class="row">
                                            <div class=" col-lg-11 col-sm-11 col-xs-11 col-md-11">
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3 " for="process_name">步骤名称：</label>
                                                    <div class=" col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        <input type="text" id="txtProcessName" class="form-control" maxlength="20" name="txtProcessName" placeholder="步骤名称">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3 " for="selectRole">审批角色：</label>
                                                    <div class=" col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        @*<input type="text" id="txtRole" class="form-control" maxlength="20" name="txtRole" placeholder="审批角色">*@
                                                        <select class="selectpicker" id="selectRole" @*multiple*@ data-width="100%"></select>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3 " for="selectBtn">操作权限：</label>
                                                    <div class=" col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        <select class="selectpicker" id="selectBtn" multiple data-width="100%"></select>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3 " for="selectOperation">审批操作：</label>
                                                    <div class=" col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        <select class="selectpicker" id="selectOperation" multiple data-width="100%"></select>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3 " for="txtFunction">提交类型：</label>
                                                    <div class=" col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        <input type="number" id="txtFunction" class="form-control" value="1" maxlength="20" name="txtFunction" placeholder="Function">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3 " for="txtBack">退回操作：</label>
                                                    <div class=" col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        @*<input type="text" id="txtBack" class="form-control" maxlength="20" name="txtBack" placeholder="退回操作">*@
                                                        <select class="selectpicker" id="selectBack" data-width="100%"></select>

                                                    </div>
                                                </div>

                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                            <div class="tab-pane " id="Set2">
                                <div class="box-body">
                                    <form class="form-horizontal" id="AttributeFormID">
                                        <div class="row">
                                            <div class=" col-lg-11 col-sm-11 col-xs-11 col-md-11">
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3 " for="process_name">流转条件：</label>
                                                    <div class=" col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        <input type="text" id="txtCondition" class="form-control" maxlength="100" name="txtCondition" placeholder="流转条件">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3 " for="txtApproval">流转方式：</label>
                                                    <div class=" col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        @*<input type="text" id="txtProcessName" class="form-control" maxlength="20" name="txtApproval" placeholder="流转方式">*@
                                                        <select class="selectpicker" id="selectApproval" data-width="100%">
                                                            @*<option value="S">单人审批</option>
                                                                <option value="M">多人审批</option>*@
                                                        </select>
                                                    </div>
                                                    <label style="padding-top: 7px;" data-toggle="tooltip" id="lblApproval"><i class=" icon-question-sign"></i></label>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3" for="selectItem">审批意见：</label>
                                                    <div class="  col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        <select class="selectpicker" id="selectItem" multiple data-width="100%"></select>
                                                    </div>
                                                    <label style="padding-top: 7px;" data-toggle="tooltip" id="lblItem"><i class=" icon-question-sign"></i></label>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3" for="txtOther">其他标识：</label>
                                                    <div class="  col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        <input type="text" maxlength="50" class="form-control" id="txtOther" name="txtOther" placeholder="其他标识（Other）" />
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-lg-3 col-sm-3 col-xs-3 col-md-3" for="txtAtten">注意标识：</label>
                                                    <div class="  col-lg-8 col-sm-8 col-xs-8 col-md-8">
                                                        <input type="text" maxlength="50" class="form-control" id="txtAtten" name="txtAtten" placeholder="注意标识（Atten）" />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer" style="padding:5px;    text-align: center;">
                    <button id="btnSave" type="submit" class="btn btn-success">
                        <i class="fa fa-floppy-o"></i> 保存
                    </button>
                    <button id="btnClose" class="btn btn-primary">
                        <i class="fa fa-times"></i> 关闭
                    </button>
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" id="hidID" />
    <!--右键菜单 div-->
    <div id="processMenu" style="display:none;">
        <ul style="width:160px">
            <li id="setting"><i class=" icon-wrench"></i>&nbsp;<span class="_label" data-toggle="modal">设置</span></li>
            @*<li id="begin"><i class="icon-play"></i>&nbsp;<span class="_label">设为第一步</span></li>
                <li id="addson"><i class="icon-plus"></i>&nbsp;<span class="_label">添加子步骤</span></li>*@
            @*<li id="copy"><i class="icon-check"></i>&nbsp;<span class="_label">复制</span></li>*@
            <li id="delete"><i class="icon-trash"></i>&nbsp;<span class="_label">删除</span></li>
            <li id="attribute"><i class="icon-cog"></i>&nbsp;<span class="_label" data-toggle="modal">属性</span></li>
        </ul>
    </div>
    <div id="canvasMenu" style="display:none;">
        <ul>
            <li id="add"><i class="icon-plus"></i>&nbsp;<span class="_label">添加步骤</span></li>
            <li id="save"><i class="icon-ok"></i>&nbsp;<span class="_label">保存设计</span></li>
            <li id="refresh"><i class="icon-refresh"></i>&nbsp;<span class="_label">刷新 F5</span></li>
            @*<li id="paste"><i class="icon-share"></i>&nbsp;<span class="_label">粘贴</span></li>*@
            @*<li id="help"><i class="icon-search"></i>&nbsp;<span class="_label">帮助</span></li>*@
        </ul>
    </div>
    <!--绘图面板 div-->
    <div class="container mini-layout canvasArea " id="flowdesign_canvas">
    </div>

    <script src="~/FlowJs/js/jquery-1.7.2.min.js"></script>
    <script src="~/FlowJs/css/bootstrap/js/bootstrap.min.js"></script>
    @*<script src="~/Scripts/bootstrap.js"></script>*@
    <script src="~/FlowJs/js/jquery-ui/jquery-ui-1.9.2-min.js"></script>
    <script src="~/FlowJs/js/jsPlumb/jquery.jsPlumb-1.3.16-all-min.js"></script>
    <script src="~/FlowJs/js/jquery.contextmenu.r2.js"></script>
    <!--select 2-->
    <script src="~/FlowJs/js/jquery.multiselect2side/js/jquery.multiselect2side.js"></script>
    <script src="~/FlowJs/js/flowdesign/leipi.flowdesign.v2.js?bata.v15"></script>
    <script src="~/FlowJs/BootstrapSelect/js/bootstrap-select.js?v1" charset="euc-jp"></script>
    <script>
        var activeID = 0;
        var FlowID = '@ViewBag.FlowID';
        $(function () {

            $("#BtnBack").click(function () {
                window.history.back();

            })


            var alertModal = $('#alertModal'), attributeModal = $("#attributeModal");
            //消息提示
            mAlert = function (messages, s) {

                if (!messages) messages = "";

                if (!s) s = 2000;

                alertModal.find(".modal-body").html(messages);

                alertModal.modal('toggle');

                setTimeout(function () { alertModal.modal("hide") }, s);

            }
            //属性设置
            attributeModal.on("hidden", function () {

                $(this).removeData("modal");//移除数据，防止缓存

            });
            ajaxModal = function (url, fn) {
                $.ajax({
                    url: url,
                    dataType: "json",
                    async: false,
                    success: function (data) {

                    }
                })
                $("#attributeModal").modal("show");
            }
            function page_reload() {
                location.reload();
            }
            /*步骤数据*/
            //var processData2 =
            //{
            //    "total": 2,
            //    "list": {
            //        "37": {
            //            "id": "37",//当前步骤ID
            //            "flow_id": "8",//所属流程ID
            //            "process_name": "填写表单",//步骤名称
            //            "process_to": "38,39",//下一步 多个用 逗号隔开
            //            "icon": "icon-play",//图标
            //            "style": "left:183px;top:68px;color:#0e76a8;"//样式
            //        },
            //        "38": { "id": "38", "flow_id": "8", "icon": "icon-plane", "process_name": "部门主管审批", "process_to": "39", "style": "left:133px;top:184px;width:200px;height:30px" },
            //        "39": { "id": "39", "flow_id": "8", "icon": "icon-star-empty", "process_name": "老板审批", "process_to": "0", "style": "left:133px;top:338px;width:200px;height:50px" }
            //    }
            //};
            var processData = {};
            $.ajax({
                url: "/Home/AjaxData?FlowID=" + FlowID,
                //dataType: "json",
                //必须同步加载
                async: false,
                success: function (data) {
                    //console.log(data);
                    processData = JSON.parse(data);
                }
            })
            /*创建流程设计器*/
            var _canvas = $("#flowdesign_canvas").Flowdesign({
                "processData": processData
                /*画面右键*/
                              , canvasMenus: {
                                  //右键添加
                                  "add": function (t) {
                                      AddPro();
                                  },
                                  //保存
                                  "save": function (t) {
                                      var processInfo = _canvas.getProcessInfo();//连接信息
                                      //alert(processInfo);
                                      $("#save").click();
                                      console.log(processInfo);
                                  },
                                  //刷新
                                  "refresh": function (t) { _canvas.refresh(); },
                                  "paste": function (t) {
                                      var pasteId = _canvas.paste();//右键当前的ID
                                      if (pasteId <= 0) {
                                          alert("你未复制任何步骤");
                                          return;
                                      }
                                      alert("粘贴:" + pasteId);
                                  },
                                  "help": function (t) {
                                      alert("暂未使用");
                                  }
                              }
                /*步骤右键*/
                              , processMenus: {
                                  "setting": function (t) {
                                      //var activeId = _canvas.getActiveId();//右键当前的ID
                                      //alert("设置:" + activeId);
                                      var activeId = _canvas.getActiveId();//右键当前的ID
                                      var url = "/Home/AjaxGetDetail";
                                      GetData(url, activeId);
                                  },
                                  "begin": function (t) {
                                      var activeId = _canvas.getActiveId();//右键当前的ID
                                      alert("设为第一步:" + activeId);
                                  },
                                  "addson": function (t) {
                                      var activeId = _canvas.getActiveId();//右键当前的ID
                                      alert("添加子步骤:" + activeId);
                                  },
                                  "copy": function (t) {
                                      //var activeId = _canvas.getActiveId();//右键当前的ID
                                      _canvas.copy();//右键当前的ID
                                      alert("复制成功");
                                  },
                                  "delete": function (t) {
                                      var activeId = _canvas.getActiveId();//右键当前的ID  $(t).attr('process_id');//
                                      if (confirm("删除:" + activeId)) {
                                          var url = "/Home/DeleteFlow";
                                          $.post(url, { "id": activeId }, function (data) {
                                              if (data.statu == 1) {
                                                  page_reload();//刷新加载页面
                                              }
                                              else {
                                                  alert("删除失败");
                                              }
                                          }, 'json');

                                          //_canvas.delProcess(activeId);
                                          //_canvas.refresh();
                                      }
                                  },
                                  "attribute": function (t) {
                                      var activeId = _canvas.getActiveId();//右键当前的ID
                                      var url = "/Home/AjaxGetDetail";
                                      GetData(url, activeId);
                                      ////alert("属性:"+activeId);
                                      ////$("#attributeModal").modal("show");
                                      //ajaxModal('/Home/AjaxGetDetail?id=' + activeID, function () {
                                      //    //alert('加载完成执行')
                                      //});
                                  }
                              }
                              , fnRepeat: function () {
                                  //alert("步骤连接重复1");//可使用 jquery ui 或其它方式提示
                                  mAlert("步骤连接重复了，请重新连接");
                              }
                              , fnClick: function () {
                                  alert("单击了节点");
                              }
                              , fnDbClick: function () {
                                  alert("双击了节点");
                              }
            });

            /*保存*/
            $("#save").click(function () {
                var processInfo = _canvas.getProcessInfo();//连接信息
                var url = "/Home/AjaxSaveProcess?FlowID=" + FlowID;
                $.post(url, { "FlowInfo": processInfo }, function (data) {
                    if (data.statu == 1) {
                        //成功
                        //mAlert("保存成功");
                        location.reload();//刷新加载页面
                    }
                    else {
                        mAlert("保存失败");

                    }
                }, 'json');

                //alert(processInfo);
                console.log(processInfo);
            })
            //$("#save").bind('click', function () {

            //});
            /*清除*/
            $("#clear").bind('click', function () {
                if (_canvas.clear()) {
                    //alert("清空连接成功");
                    mAlert("清空连接成功，你可以重新连接");
                } else {
                    //alert("清空连接失败");
                    mAlert("清空连接失败");
                }
            });

        })
        //回显步骤详情数据
        function GetData(url, activeId) {
            $.post(url, { "id": activeId }, function (data) {
                if (data.statu == 1) {
                    $("#hidID").val(data.data.id);
                    $("#txtProcessName").val(data.data.process_name);
                    $("#txtFunction").val(data.data.FunctionType);
                    $("#txtOther").val(data.data.Other);
                    $("#txtAtten").val(data.data.Atten);
                    $("#txtCondition").val(data.data.Condition);
                    if (data.data.BackID != "" && data.data.BackID != null) {
                        $('#selectBack').selectpicker('val', parseInt(data.data.BackID));//默认选中
                    }
                    if (data.data.Approval != "" && data.data.Approval != null) {
                        $('#selectApproval').selectpicker('val', data.data.Approval);//默认选中
                    }
                    if (data.data.SuggesItem != "" && data.data.SuggesItem != null) {
                        var SuggesItem = new Array();
                        SuggesItem = data.data.SuggesItem.split(",");
                        var dataIntArr = [];//保存转换后的整型字符串
                        SuggesItem.forEach(function (data, index, arr) {
                            dataIntArr.push(+data);
                        });
                        $('#selectItem').selectpicker('val', dataIntArr);//默认选中
                        // $('#selectOperation .selectpicker').selectpicker('refresh');
                    }
                    if (data.data.OperationID != "" && data.data.OperationID != null) {
                        var Operation = new Array();
                        Operation = data.data.OperationID.split(",");
                        var dataIntArr = [];//保存转换后的整型字符串
                        Operation.forEach(function (data, index, arr) {
                            dataIntArr.push(+data);
                        });
                        $('#selectOperation').selectpicker('val', dataIntArr);//默认选中
                        // $('#selectOperation .selectpicker').selectpicker('refresh');
                    }
                    if (data.data.RoleID != "" && data.data.RoleID != null) {
                        var Role = data.data.RoleID

                        $('#selectRole').selectpicker('val', parseInt(Role));//默认选中
                        // $('#selectRole .selectpicker').selectpicker('refresh');
                    }
                    if (data.data.Buttons != "" && data.data.Buttons != null) {
                        var Btn = new Array();
                        Btn = data.data.Buttons.split(",");
                        var dataIntArr = [];//保存转换后的整型字符串
                        Btn.forEach(function (data, index, arr) {
                            dataIntArr.push(+data);
                        });
                        $('#selectBtn').selectpicker('val', dataIntArr);//默认选中
                        // $('#selectBtn .selectpicker').selectpicker('refresh');
                    }

                    $("#attributeModal").modal("show");
                }
                else {
                    alert("删除失败");
                }
            }, 'json');
        }
        //添加步骤
        function AddPro() {
            var mLeft = $("#jqContextMenu").css("left"), mTop = $("#jqContextMenu").css("top");
            //**************页面添加新步骤
            //var info = { id: Math.ceil(Math.random() * 1000), flow_id: 2141, process_name: "新建步骤", process_to: "", icon: "", style: "left:" + mLeft + ";top:" + mTop + ";color:#0e76a8;" };
            //_canvas.addProcess(info);
            //**************服务器添加步骤
            var model = {
                flow_id: FlowID,
                process_name: "新建步骤",
                process_to: "",
                icon: "",
                style: "left:" + mLeft + ";top:" + mTop + ";color:#0e76a8;"
            }
            var url = "/Home/AddFlow";
            $.post(url, { "Flow": model }, function (data) {
                if (data.statu == 1) {
                    location.reload();
                    //page_reload();//刷新加载页面
                }
                else {
                    alert("添加失败");
                }
            }, 'json');
        }
    </script>
    <script>
        var flowID = "@ViewBag.FlowID";
        $(function () {

            AjaxBindBtn();
            AjaxBindOperation();
            AjaxBindRole();
            AjaxBindItem();
            AjaxBindBack();
            AjaxBindApproval();
            //$("[name='rtu.state']").val(data.state);
            //$('[name="rtu.state"]').selectpicker('refresh');
            // $('[name="rtu.state"]').selectpicker('render');
            $("#lblApproval").popover({
                trigger: 'hover',
                html: true,
                placement: 'bottom',
                content: 'S：单人审批（当前环节一人审批后就可以流转）。<br> M：多人审批（当前环节全部审核通过后才进行流转）'
            });
            $("#lblItem").popover({
                trigger: 'hover',
                html: true,
                placement: 'bottom',
                content: '快捷审批意见选项'
            });
            $("#btnClose").click(function () {
                $("#attributeModal").modal("hide");
            })
            $("#btnSave").click(function () {
                //$("#hidID").val(data.data.id);
                //$("#txtProcessName").val(data.data.process_name);
                //$("#txtFunction").val(data.data.FunctionType);
                //$("#txtBack").val(data.data.BackID);
                var btnArray = $('#selectBtn').selectpicker('val');
                if (btnArray != null) {
                    btnArray = btnArray.join();
                }
                else {
                    btnArray = "";
                }

                var oprArray = $('#selectOperation').selectpicker('val');
                if (oprArray != null) {
                    oprArray = oprArray.join();
                }
                else {
                    oprArray = "";
                }
                var Item = $('#selectItem').selectpicker('val');
                if (Item != null) {
                    Item = Item.join();
                }
                else {
                    Item = "";
                }
                var Process = {
                    id: $("#hidID").val(),
                    process_name: $("#txtProcessName").val(),
                    FunctionType: $("#txtFunction").val(),
                    BackID: $('#selectBack').selectpicker('val'),
                    Buttons: btnArray,
                    OperationID: oprArray,
                    RoleID: $('#selectRole').selectpicker('val'),
                    Approval: $('#selectApproval').selectpicker('val'),
                    SuggesItem: Item,
                    Other: $("#txtOther").val(),
                    Atten: $("#txtAtten").val(),
                    Condition: $("#txtCondition").val()
                };
                $.ajax({
                    url: "/home/AjaxSaveDetail",
                    type: "POST",
                    data: Process,
                    dataType: "json",
                    async: true,
                    success: function (data) {
                        if (data != null && data != "") {
                            if (data.statu == 1) {
                                $("#attributeModal").modal("hide");
                                location.reload();//刷新加载页面
                            }
                            else {
                                alert("保存失败");
                            }
                        }
                    }
                })
            })

        })

        function ClearText() {
            $("#hidID").val('');
            $("#txtProcessName").val('');
            $("#txtFunction").val(1);
            $("#txtAtten").val('');
            $("#txtOther").val('');

            AjaxBindBtn();
            AjaxBindOperation();
            AjaxBindRole();
            AjaxBindItem();
            AjaxBindBack();
            AjaxBindApproval();
        }

        //绑定操作权限
        function AjaxBindBtn() {
            $.ajax({
                url: "/home/AjaxGetBtn",
                type: "POST",
                dataType: "json",
                async: true,
                success: function (data) {
                    $.each(data, function (i) {
                        //$("<option></option>").val(data[i].Id).text(data[i].Text).appendTo($("#selectBtn"));
                        $("<option value='" + data[i].Id + "'>" + data[i].Text + "</option>").appendTo("#selectBtn");
                    });
                    $('.selectpicker').selectpicker('refresh');
                }
            })
        }
        //绑定角色
        function AjaxBindRole() {
            //
            $.ajax({
                url: "/home/AjaxGetRole?FlowID=" + flowID,
                type: "POST",
                dataType: "json",
                async: true,
                success: function (data) {
                    $("<option value='0'>请选择</option>").appendTo("#selectRole");
                    $.each(data, function (i) {
                        $("<option value='" + data[i].Id + "'>" + data[i].Text + "</option>").appendTo("#selectRole");
                    });
                    $('.selectpicker').selectpicker('refresh');
                }
            })
        }
        //绑定操作类型
        function AjaxBindOperation() {
            $.ajax({
                url: "/home/AjaxGetOperation",
                type: "POST",
                dataType: "json",
                async: true,
                success: function (data) {
                    $.each(data, function (i) {
                        $("<option value='" + data[i].Id + "'>" + data[i].Text + "</option>").appendTo("#selectOperation");
                    });
                    $('.selectpicker').selectpicker('refresh');
                }
            })
        }
        //绑定审批意见
        function AjaxBindItem() {
            //
            $.ajax({
                url: "/home/AjaxGetItem",
                type: "POST",
                dataType: "json",
                async: true,
                success: function (data) {
                    $.each(data, function (i) {
                        $("<option value='" + data[i].Id + "'>" + data[i].Text + "</option>").appendTo("#selectItem");
                    });
                    $('.selectpicker').selectpicker('refresh');
                }
            })
        }
        //获取可退回步骤
        function AjaxBindBack() {
            $.ajax({
                url: "/home/AjaxGetBackProcess?FlowID=" + flowID,
                type: "POST",
                dataType: "json",
                async: true,
                success: function (data) {
                    $.each(data, function (i) {
                        $("<option value='" + data[i].Id + "'>" + data[i].Text + "</option>").appendTo("#selectBack");
                    });
                    $('.selectpicker').selectpicker('refresh');
                }
            })
        }
        function AjaxBindApproval() {
            $("<option value='S'>单人审批</option>").appendTo("#selectApproval");
            $("<option value='M'>多人审批</option>").appendTo("#selectApproval");
            $('.selectpicker').selectpicker('refresh');
        }
    </script>
</body>

</html>
